const express = require('express')
const router = express.Router()
const routeName = 'users'
const userValidator = require('../role/user')
// 用户登录
router.post(`/${routeName}/login`, async (req, res, next) => {
  try {
    // 处理请求
    res.send('POST-/users/login')
  } catch (err) {
    next(err)
  } 
})
// 用户注册
router.post(`/${routeName}`,userValidator.register, require('../controller/user').userRegister) // 通过验证,执行具体结果的控制器
// 获取当前登录用户
router.get(`/${routeName}`, async (req, res, next) => {
    try {
      // 处理请求
      res.send('get-/users')
    } catch (err) {
      next(err)
    } 
})
// 更新用户
router.patch(`/${routeName}`, async (req, res, next) => {
    try {
      // 处理请求
      res.send('patch-/users')
    } catch (err) {
      next(err)
    } 
})
module.exports = router